package net.dgg.rz.production.dao;

import net.dgg.rz.production.entity.ProductNodeOperating;
import net.dgg.rz.production.entity.ProductOrder;
import net.dgg.rz.production.entity.dto.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 生产订单dao
 * Created by zyou on 2018/12/17.
 */


@Component
public interface ProductOrderDao {

    /**
     * 生产订单
     *
     * @param params
     * @return
     */
    List<ProductOrderDto> scOrderWithPage(Map params);


    List<ProductOrderDto> scOrderForAuditWithPage(Map params);

    /**
     * 更新
     *
     * @param record
     * @return
     */
    void updateByPrimaryKeySelective(ProductOrder record);

    /**
     * 插入
     *
     * @param productorder
     * @return
     */
    void insertSelective(ProductOrder productorder);

    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    ProductOrder selectByPrimaryKey(Long id);

    ProductOrderDto selectDtoByPrimaryKey(Long id);

    /**
     * @return
     * @Author Quanlin Wan
     * @Description //TODO 批量更新
     * @Date 13:46 2018/12/26
     * @Param
     **/
    void updateBatchById(ProductOrder productOrder);

    void updateBatchByIds(@Param("productOrder") ProductOrder productOrder, @Param("orderIdList") List<Long> orderIdList);


    List<ProductOrder> selectByPrimaryKeys(@Param("scProductOrderIdList") List<Long> scProductOrderIdList);

    /**
     * 根据销售主订单编号查询销售子订单列表
     *
     * @param orderId    销售主订单Id
     * @param orderBusId 销售子订单id，排除该子订单，用于查询相关订单
     * @return
     */
    List<ProductOrder> getListByOrderId(@Param("orderId") long orderId, @Param("orderBusId") Long orderBusId, @Param("id") Long id);

    List<ProductOrder> selectByOrderIdSelective(@Param("orderId") long orderId, @Param("statusArr") List<String> statusArr);

    Map selectScOrderCountTotal(Map param);

    List<Map> selectScOrderCount(Map param);

    List<ProductOrder> getOrgOrderListWithPage(Map params);

    /**
     * <p>@Description 接口专用: 根据销售订单ID查询所有生产订单信息</p>
     * <p>@author zyou</p>
     * <p>@Time 2019/2/26  14:41 创建时间</p>
     * <p>@return</p>
     */

    List<Map> queryProductOrderByOrderId(HashMap orderId);

    ProductOrder queryLatestScOrder(Map<String, Object> params);

    List<ProductOrder> queryAllScorder(Long orderId);

    List<LinkedHashMap> queryBusinessProgress(Map<String, Object> params);

    List<Map> queryLoanMoneyByOrderId(HashMap orderId);

    /**
     * 通过销售子单查询
     *
     * @param orderBusinessId
     * @return
     */
    List<ProductOrder> getByOrderBusinessId(Long orderBusinessId);

    /**
     * @return
     * @Author Quanlin Wan
     * @Description //TODO 查询orderId下未完成的生产订单
     * @Date 11:04 2019/3/27
     * @Param
     **/

    Integer selectUnfinlishOrder(@Param("orderId") Long orderId, @Param("statusArr") List<String> statusArr);

    /**
     * @param orderNo 销售订单No
     * @return
     * @Author Quanlin Wan
     * @Description //TODO 查询生产订单数量(不包括已逻辑删除的)
     * @Date 10:43 2019/3/28
     **/
    Integer selectOrderCount(@Param("orderNo") String orderNo);

    /**
     * 获取所有并且flag为0的且已放款生产子单销售子单id集合
     *
     * @param orderId
     * @return
     */
    List<Long> getByOrderId(Long orderId);

    /**
     * 首先查询是否是crm4.0老数据，如果是（没有查到生产单，就返回是老数据，告诉财务可以认款）
     *
     * @return
     */
    int countOrderByOrderId(Long orderId);

    /**
     * @return
     * @Author chenyang
     * @Description APP 融资生产页面数据统计
     **/
    Map<String, Object> statisticFinancingDataCount(Map<String, Object> params);

    Long statisticHandle(Map<String, Object> params);

    Long statisticExamine(Map<String, Object> params);

    /**
     * @return
     * @Description APP 待接收页面数据接口
     * @Author chenyang
     **/

    List<ProductOrderDto> waitReceivedOrderWithPage(Map<String, Object> params);

    /**
     * @return
     * @Description APP 所有订单列表接口
     * @Author chenyang
     **/

    List<ProductOrderDto> findProductOrderWithPage(Map<String, Object> params);


    /**
     * @return
     * @Author Quanlin Wan
     * @Description //TODO 生产明细数据列表数据接口
     * @Date 10:26 2019/4/29
     * @Param
     **/

    List<ProductOrderDetatilDto> scOrderDetatilWithPage(Map<String, Object> params);

    /**
     * @return
     * @Description 跟进中统计抵押贷款报表汇总
     * @Author chenyang
     **/

    Map<String, Object> findMortgageLoanCount(Map<String, Object> params);

    /**
     * @return
     * @Description 跟进中统计信用贷款报表汇总
     * @Author chenyang
     **/
    Map<String, Object> findCreditLoanCount(Map<String, Object> params);

    Map<String,Object> countCreditList(Map<String, Object> params);

    /**
     * @return
     * @Description 跟进中统计资金业务报表汇总
     * @Author chenyang
     **/
    Map<String, Object> findCapitalBusinessCount(Map<String, Object> params);

    /**
     * @return
     * @Description 跟进中统计报表列表部分
     * @Author chenyang
     **/
    List<Map<String, Object>> getFollowUpReportWithPage(Map<String, Object> params);

    List<ProductOrderDto> findScorderByCustomerId(Map params);

    /**
     * @Author Quanlin Wan
     * @Description //TODO 跟进中明细列表返回数据
     * @Date 14:15 2019/5/7
     * @Param
     * @return
     **/
    List<ProcessingOrderDetatilDto> processingDetatilWithPage(Map params);


    /**
     * @return
     * @Description 后台数据统计报表汇总
     * @Author chenyang
     **/

    Map<String, Object> findBackGroundReportCount(Map<String, Object> params);

    /*Map<String, Object> BackGroundReportCount(Map<String, Object> params);

    Map<String, Object> BackGroundCount(Map<String, Object> params);*/

    Map<String, Object> countMortgageList(Map<String, Object> data);
    /**
     * 修改生产订单信息
     * @param updateGsscOrder
     * @return
     */
    int updateOrderInfo(UpdateGsscOrderDto updateGsscOrder);

    /**
     * @Title:
     * @Description: TODO 企大宝生产订单ID获取业务办理进度顺序排列
     * @param:
     * @return:
     * @throw:
     * @author: sdx
     * @creat_date: 2019/12/06
     **/
    List<ProductNodeOperating> getProductOrderById(Map map);

    /**
     * @Title:
     * @Description: TODO 企大宝生产订单ID获取业务办理进度顺序排列
     * @param:
     * @return:
     * @throw:
     * @author: sdx
     * @creat_date: 2019/12/06
     **/
    List<ProductNodeOperating> getProductNodeById(Map map);

    List<ProductOrderDto> selectByOrderIds(@Param("scOrderIds") List<Long> scOrderIds);



    List<ProductOrder> queryByOrderIds(@Param("scOrderIds") List<Long> scOrderIds);

    /**
     * 根据生产单id查询生产主订单
     * @param scOrderId
     * @return
     */
	ProductOrder getMainOrderByScOrderId(@Param("scOrderId")String scOrderId);

    /**
     * 修改生产单售后状态
     * @param productOrder
     */
    void updateAfterSaleStatus(ProductOrder productOrder);

    /**
     * 根据订单编号修改是否发送接单触发短信状态
     * @param orderNo
     */
    void updateSendSms(@Param("orderNo") String orderNo);

    /**
     * 根据客户ID修改客户名称
     * @param customerId
     * @param customerName
     */
    void updateCustomerName(@Param("customerId") String customerId, @Param("customerName") String customerName);



    /**
     * 生产订单
     *
     * @param params
     * @return
     */
    List<UploadWjOrderDto> queryOrderWjsh(Map params);
}
